{extend name="public/base"/}
 {block name="content"}
  <section class="content">
            <div class="col-md-9" style="width:100%">
              <div class="box box-default">
			<div class="box-header">
      <h3 class="box-title" ><a href="{:U('Coupon/index')}" class="btn btn-primary">领取者名单</a></h3>      
      <h3 class="box-title" ><a href="{:U('Coupon/generate')}" class="btn btn-primary">生成优惠券</a></h3>
      <h3 class="box-title" ><a href="{:U('Coupon/grant')}" class="btn btn-primary">发放优惠券</a></h3>
				
			</div>
				<!-- /.box-header -->
                <!-- form start -->
                  <form action="{:U('Coupon/grant')}" method="post">
                <div class="box-body">
                  <div class="row">
                    <div class="col-md-12">
                      <table class="table table-bordered">
					  
					  	<tr>
                            <th width="140">发放给楼盘:</th>
                        <td>						
							<select name="id" class="form-control" id="loupan">
							<option value="0">请选择楼盘</option>
                            {volist name="pantype" id="data"}
							              <option value="{$data.id}">{$data.name}</option>
                            {/volist}
						     </select>
						</td>
                        </tr> 
                        <script>
                        $(document).ready(function(){
                          $("#loupan").change(function(){
                            var test =  $("#loupan option:selected").val();
                                  $.post("{:U('Coupon/ajax')}",{lid:test},function(data){
                                      $("#numb").text(data);
                                     if(data == "0张"){
                                       $("#msg").html('<div style="background-color:#ecf0f5;border:none;"class="btn btn-primary">已无优惠券</div>');
                                     }else{
                                       $("#msg").html(' <button type="submit" class="btn btn-primary">发放</button>');                                      
                                     }
                                    },'json');
                                  
                          });
                          
                        });
                        </script>
                         <tr>
                            <th width="140">剩余数量:</th>
                            <td><span id="numb">1000张<span></td>
                        </tr>
                         <tr>
                            <th width="140">发放数量:</th>
                            <td><input class="form-control" type="text" name="nums" value="0" size="30"></td>
                        </tr>						  
					
                      </table>
                    </div><!-- /.col -->
                  </div><!-- /.row -->
                </div><!-- /.box-body -->
                <div class="box-footer" id="msg">
                  <button type="submit" class="btn btn-primary">发放</button>
                </div>
				</form>
              
              </div><!-- /.box -->
            </div>
			<!-- /.col -->
			</section>
 {/block}
